#pragma once

#include <assert.h>

template <typename T>
class Stack
{
public:
	static const int Max_Data_Len = 200;
	Stack();
	~Stack();

	bool IsEmpty()
	{
		return _top < 0;
	}

	bool Pop(T *c = nullptr)
	{
		if (_top < 0)
		{
			return false;
		}
		if (nullptr != c)
		{
			*c = _data[_top];
		}
		--_top;
		return true;
	}

	bool Push(const T& c)
	{
		if (_top >= Max_Data_Len)
		{
			return false;
		}
		++_top;
		_data[_top] = c;
		return true;
	}

	T getTop()
	{
		assert(_top >= 0);
		return _data[_top];
	}

private:
	int _top;
	T _data[Max_Data_Len];
};

template <typename T>
Stack<T>::Stack() : _top(-1)
{
}

template <typename T>
Stack<T>::~Stack()
{
}

